package com.to8to.scene.datatransfer;

import java.sql.Connection;
import java.sql.SQLException;
import java.util.HashMap;
import java.util.Map;

import org.apache.commons.configuration.ConfigurationException;
import org.apache.commons.configuration.PropertiesConfiguration;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.mongodb.BasicDBObject;
import com.mongodb.DBCursor;
import com.to8to.commons.mongo.MongoClientBase;
import com.to8to.commons.utils.ThriftUtil;
import com.to8to.scene.data.DataFixIface;
import com.to8to.scene.server.Commons;
import com.to8to.scene.server.Tables;
import com.to8to.thrift.diary.module.TStType;

/**
 * FixStaticConfigCateType2.java
 * 作 者:alpha.ren
 * 版 本:v2.0
 * 日期:2015年1月12日
 * 描 述:添加相应二级分类
 */
public class FixStaticConfigCateType2 implements DataFixIface
{
    public static Logger logger = LoggerFactory.getLogger(FixStaticConfigCateType2.class);

    static Connection conn;

    public void fix(Connection mysql, MongoClientBase mongo) throws SQLException
    {
        DBCursor static_conf_cur =
            mongo.cursor(Tables.StaticConfigValue, new BasicDBObject("type_name", "progress_type_2"), null, new BasicDBObject("parent_type_id", 1), 0, 0);

        //设计费
        Map<String, String> other_map = new HashMap<String, String>();
        other_map.put("27", "设计效果图");
        other_map.put("28", "设计施工图");

        TStType progress_type_2_sheji = new TStType();
        progress_type_2_sheji.setLevel(2);
        progress_type_2_sheji.setParent_type_id("6");
        progress_type_2_sheji.setId_map(other_map);
        progress_type_2_sheji.setType_name("category_type_2");
        mongo.insert(Tables.StaticConfigValue, ThriftUtil.thriftObject2DBObject(progress_type_2_sheji));
        logger.debug("insert {} for {}", Tables.StaticConfigValue, ThriftUtil.thriftObject2DBObject(progress_type_2_sheji));

        //装修费
        //29.验房费 30.货运搬运费 31.管理费 32.保洁费 33.垃圾处理 34.水电改造 35.燃气改造 36.网络改造 37.防水人工辅材 38.瓦工人工辅材 39.木工人工辅材 40.油漆人工辅材 41.地热暖气改造 42.窗门改造 43.楼梯改造 43.阳台改造 44.花园改造 45.房屋吊顶 46.拆墙打孔 47.其他费用
        other_map = new HashMap<String, String>();
        other_map.put("29", "验房费");
        other_map.put("30", "货运搬运费");
        other_map.put("31", "管理费");
        other_map.put("32", "保洁费");
        other_map.put("33", "垃圾处理");
        other_map.put("34", "水电改造");
        other_map.put("35", "燃气改造");
        other_map.put("36", "网络改造");
        other_map.put("37", "防水人工辅材");
        other_map.put("38", "瓦工人工辅材");
        other_map.put("39", "木工人工辅材");
        other_map.put("40", "油漆人工辅材");
        other_map.put("41", "地热暖气改造");
        other_map.put("42", "窗门改造");
        other_map.put("43", "楼梯改造");
        other_map.put("44", "阳台改造");
        other_map.put("45", "花园改造");
        other_map.put("46", "房屋吊顶");
        other_map.put("47", "拆墙打孔");
        other_map.put("48", "其他费用");

        TStType progress_type_2_zhuangxiufei = new TStType();
        progress_type_2_zhuangxiufei.setLevel(2);
        progress_type_2_zhuangxiufei.setParent_type_id("7");
        progress_type_2_zhuangxiufei.setId_map(other_map);
        progress_type_2_zhuangxiufei.setType_name("category_type_2");
        mongo.insert(Tables.StaticConfigValue, ThriftUtil.thriftObject2DBObject(progress_type_2_zhuangxiufei));
        logger.debug("insert {} for {}", Tables.StaticConfigValue, ThriftUtil.thriftObject2DBObject(progress_type_2_zhuangxiufei));
    }

    public static void main(String[] args) throws SQLException, ConfigurationException
    {
        PropertiesConfiguration pc = new PropertiesConfiguration("common.properties");

        Commons.init(null);

        (new FixStaticConfigCateType2()).fix(conn, Commons.mongo);

        conn.close();
    }
}
